package com.hlw.hr_man.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.hlw.hr_man.Model.DeptModel;
import com.hlw.hr_man.Model.EmployeeModel;
import com.hlw.hr_man.service.EmployeeSrevice;
import com.hlw.hr_man.service.FindDeptService;
import com.hlw.hr_man.serviceImpl.EmployeeServiceImpl;
import com.hlw.hr_man.serviceImpl.FindDeptServiceImpl;
import com.sun.org.apache.bcel.internal.generic.NEW;
/**
 * 添加员工信息
 * @author Windy--Chow
 *
 */
public class AddEmployeecontroller extends HttpServlet{
	    EmployeeSrevice employee = new EmployeeServiceImpl();
	   
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        	// TODO Auto-generated method stub
        	doPost(req, resp);
        }
        @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // TODO Auto-generated method stub
        	req.setCharacterEncoding("utf8");
            resp.setCharacterEncoding("utf8");
            PrintWriter pw = resp.getWriter();
            String e_number = req.getParameter("e_number");
            String e_name = req.getParameter("e_name");
            String e_sex = req.getParameter("e_sex");
            int  e_age = Integer.parseInt(req.getParameter("e_age"));
            String e_tel = req.getParameter("e_tel");
            String e_email = req.getParameter("e_email");
            String e_address = req.getParameter("e_address");
            String e_birthday = req.getParameter("e_birthday");
            String e_entrydate = req.getParameter("e_entrydate");
            String e_description = req.getParameter("e_description");
            int  dept_id =  Integer.parseInt(req.getParameter("dept_id"));
            int  role_id = Integer.parseInt(req.getParameter("role_id"));
            String e_password  = req.getParameter("e_password");
            EmployeeModel emp = new EmployeeModel(role_id, e_number, e_password, e_name, e_sex, e_age, e_tel, e_email, e_address, e_birthday, e_entrydate, e_description, dept_id);
            int flag = employee.insertEmployee(emp);
             pw.write(String.valueOf(flag));
             
            
        }
}
